// app/page.tsx (服务端组件默认无需 'use client')
// import { getUserData } from "../api/user/route";
import { Button, Input } from "antd";
import { MongoClient } from "mongodb";
export default async function HomePage() {
  // 直接调用 API 路由（服务端到服务端调用）
  // const data = await getUserData(); // 注意使用完整 URL
  // const data = await response.json();
  // console.log("data: ", data);
  const url = "mongodb://localhost:27017";
  const client = new MongoClient(url);
  await client.connect();
  const db = client.db("admin");
  // await db.createCollection("roles");
  const collection = db.collection("roles");
  const data = await collection.insertOne({
    name: "管理员",
    nickName: "超级管理员",
  });
  // const data = await collection.updateOne(
  //   { id: 7 },
  //   { $set: { name: "明明就", role: "管理员" } }
  // );
  // await collection.insertOne({ name: "王鹤翔", age: 30 });
  console.log("data: ", data);
  return (
    <div>
      <Button>测试一下</Button>
      <Input />
    </div>
  );
}
